<?php
// SomeryC, a webcomic script by Zachary Weston Lewis
// Based on Somery by Robin de Graaf
// Copyright 2005-2006
// SomeryC is distributed under the Artistic License (see LICENSE.txt)
//
// ADMIN/TEAM.PHP > 31-08-2007

$start = TRUE; include("system/include.php"); if ($checkauth) { ?> 
<h1 id='team'>Team</h1>
<h2>site team</h2>
<?php 
if (!$action) { 
   $result = mysql_query("SELECT * FROM ".$prefix."users ORDER BY uid"); 
   echo "<table> 
      <tr><td><h3>name</h3></td><td><h3>level</h3></td><td><h3>title</h3></td><td colspan='2'><h3>edit</h3></td></tr>";
   while($row=mysql_fetch_object($result)) { 
      echo "<tr><td><a class='user' href='profile.php?action=view&username=$row->username'>$row->username</a></td><td>$row->level</td><td>".$levelname[$row->level]. "</td>"; 
      if ($row->level <= $userdata['level'] && $row->level != 4 && $user != $row->username && $userdata['level'] > 1) { 
         if ($row->level != 0) { 
            echo "<td><a class='minus' href='$PHP_SELF?action=adjust&type=demote&id=$row->uid'><span> - </span></a></td>";
         } elseif ($row->level == 0) { 
            echo "<td><a class='delete' href='$PHP_SELF?action=adjust&type=remove&id=$row->uid'><span> X </span></a> </td>";
         } else { 
            echo "<td></td>"; 
         } 
         if ($row->level < 3 && $userdata['level'] > $row->level) { 
            echo "<td><a class='plus' href='$PHP_SELF?action=adjust&type=promote&id=$row->uid'><span> + </span></a></td>";
         } else { 
            echo "<td></td>"; 
         } 
      } else { 
         echo "<td></td><td></td>"; 
      } 
      echo "</tr>"; 
   } 
   echo "</table>"; 
} elseif ($action == "adjust") { 
   $result = mysql_query("SELECT * FROM ".$prefix."users WHERE uid = '$id'"); 
   while($row=mysql_fetch_object($result)) { $t_level = $row->level; } 
   if ($userdata['level'] >= $t_level) { 
      if ($type == "demote") { 
         $result = mysql_query("SELECT * FROM ".$prefix."users WHERE uid = '$id'"); 
         while($row=mysql_fetch_object($result)) { $t_level = $row->level; } 
         $t_level--; 
         $result = mysql_query("UPDATE ".$prefix."users SET level = '$t_level' WHERE uid = '$id'"); 
         echo "<meta http-equiv=Refresh content=0;URL='team.php'>"; 
      } elseif ($type == "promote") { 
         $result = mysql_query("SELECT * FROM ".$prefix."users WHERE uid = '$id'"); 
         while($row=mysql_fetch_object($result)) { $t_level = $row->level; } 
         $t_level++; 
         $result = mysql_query("UPDATE ".$prefix."users SET level = '$t_level' WHERE uid = '$id'"); 
         echo "<meta http-equiv=Refresh content=0;URL='team.php'>"; 
      } elseif ($type == "remove") { 
         $result = mysql_query("SELECT * FROM ".$prefix."users WHERE uid = '$id'"); 
         while($row=mysql_fetch_object($result)) { $t_user= $row->username; } 
         $result = mysql_query("DELETE FROM ".$prefix."users WHERE uid = '$id'"); 
         $result = mysql_query("DELETE FROM ".$prefix."profile WHERE username = '$t_user'"); 
         echo "<meta http-equiv=Refresh content=0;URL='team.php'>"; 
      } 
   } else { 
      echo "invalid permissions, meaning you cant do that - <a href='$PHP_SELF'>go back</a>"; 
   } 
} 
?> 
<?php }; $start = FALSE; include("system/include.php"); ?> 
